# Copyright 2021 Arm Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Search through the neural networks made available by the neural_networks
# package and check if the targeted network exists.
#
# :param target_network_name: the name of the targeted network
# :type target_network_name: string
# :param target_network_backend: the name of the targeted backend
# :type target_network_backend: string
#
macro(autoware_check_neural_network target_network_name target_network_backend)

  normalize_path(_target_dir "@tvm_utility_NETWORKS_DIR@/${target_network_name}/${target_network_backend}")

  if(IS_DIRECTORY ${_target_dir}
    AND EXISTS "${_target_dir}/inference_engine_tvm_config.hpp"
    AND EXISTS "${_target_dir}/deploy_lib.so"
    AND EXISTS "${_target_dir}/deploy_graph.json"
    AND EXISTS "${_target_dir}/deploy_param.params"
  )
    set(${target_network_name}_FOUND TRUE)
  else()
    set(${target_network_name}_FOUND FALSE)
  endif()

endmacro()
